Imports System.Runtime.InteropServices
Imports System.Security
Imports System.Security.Permissions

'<SuppressUnmanagedCodeSecurityAttribute()> _
Friend NotInheritable Class UnsafeNativeMethods

  <DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _
  Friend Shared Function ShowWindow(ByVal handle As System.IntPtr, ByVal nCmdShow As Int32) As <MarshalAs(UnmanagedType.Bool)> Boolean
  End Function

  Public Const HWND_TOPMOST As Int32 = -1
  Public Const SWP_NOACTIVATE As Int32 = &H10
  Public Const SWP_SHOWWINDOW As Int32 = &H40
  Public Const SW_SHOWNOACTIVATE As Int32 = 4

  'Public Declare Auto Function DrawFrameControl Lib "user32.dll" (ByVal in_hdc As IntPtr, ByRef in_lprc As RECT, ByVal in_uType As int32, ByVal in_uSTate As int32) As Boolean

#Region "Task Bar Location Support Routines"


  <DllImport("shell32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _
  Friend Shared Function SHAppBarMessage(ByVal dwMessage As UInt32, ByRef pData As APPBARDATA) As UInt32
  End Function

  Public Structure FLASHWINFO
    Public cbSize As Int32
    Public hwnd As IntPtr
    Public dwFlags As Int32
    Public uCount As Int32
    Public dwTimeout As Int32
  End Structure


  'Public Declare Function FlashWindowEx Lib "user32.dll" (ByRef pfwi As FLASHWINFO) As Int32

  'Public Const FLASHW_CAPTION As Int32 = &H1
  'Public Const FLASHW_TRAY As Int32 = &H2
  'Public Const FLASHW_ALL As Int32 = (FLASHW_CAPTION Or FLASHW_TRAY)

  <System.Runtime.InteropServices.StructLayout(LayoutKind.Sequential)> _
  Public Structure APPBARDATA
    Public cbSize As Integer
    Public hWnd As IntPtr
    Public uCallbackMessage As Integer
    Public uEdge As Integer
    Public rc As RECT
    Public lParam As IntPtr
  End Structure

  <System.Runtime.InteropServices.StructLayout(LayoutKind.Sequential)> _
  Public Structure RECT
    Public Left As Int32
    Public Top As Int32
    Public Right As Int32
    Public Bottom As Int32
  End Structure

  Public Const ABM_GETTASKBARPOS As Long = &H5
  Public Const ABM_GETSTATE As Long = &H4
  Public Const ABE_TOP As Long = 1
  Public Const ABE_LEFT As Long = 0
  Public Const ABE_RIGHT As Long = 2
  Public Const ABE_BOTTOM As Long = 3

#End Region


  'Private Declare Auto Function GetWindowLong Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal nIndex As int32) As Int32
  'Private Declare Auto Function SetWindowLong Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal nIndex As int32, ByVal dwNewLong As Int32) As Int32

  'Private Const GWL_EXSTYLE As int32 = -20

  'Private Const WS_EX_TOPMOST As int32 = &H8&
  'Private Const SW_SHOWNA As int32 = 8
  'Private Const SW_NORMAL As int32 = 1

#Region "DPAPI Encryption"

  Public Const CRYPTPROTECT_UI_FORBIDDEN As Integer = &H1
  Public Const CRYPTPROTECT_LOCAL_MACHINE As Integer = &H4

  <StructLayout(LayoutKind.Sequential)> _
  Public Structure DATA_BLOB
    Public cbData As Integer
    Public pbData As IntPtr
  End Structure

  <DllImport("crypt32", CharSet:=CharSet.Auto, BestFitMapping:=False, ThrowOnUnmappableChar:=True)> _
  Public Shared Function CryptProtectData(ByRef pDataIn As DATA_BLOB, ByVal szDataDescr As String, ByRef pOptionalEntropy As DATA_BLOB, ByVal pvReserved As IntPtr, ByVal pPromptStruct As IntPtr, ByVal dwFlags As Integer, ByRef pDataOut As DATA_BLOB) As <MarshalAs(UnmanagedType.Bool)> Boolean
  End Function

  <DllImport("crypt32", CharSet:=CharSet.Auto, BestFitMapping:=False, ThrowOnUnmappableChar:=True)> _
  Public Shared Function CryptUnprotectData(ByRef pDataIn As DATA_BLOB, ByVal szDataDescr As System.Text.StringBuilder, ByRef pOptionalEntropy As DATA_BLOB, ByVal pvReserved As IntPtr, ByVal pPromptStruct As IntPtr, ByVal dwFlags As Integer, ByRef pDataOut As DATA_BLOB) As <MarshalAs(UnmanagedType.Bool)> Boolean
  End Function

  <DllImport("kernel32")> _
  Public Shared Function LocalFree(ByVal hMem As IntPtr) As IntPtr
  End Function

  <DllImport("user32.dll")> _
Public Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As UInteger) As <MarshalAs(UnmanagedType.Bool)> Boolean
  End Function

  Public Const SWP_NOSIZE As Integer = 1
  Public Const WM_CTLCOLORLISTBOX As UInt32 = 308

#End Region

  <DllImport("kernel32.dll", BestFitMapping:=False, ThrowOnUnmappableChar:=True)> _
  Public Shared Function GetShortPathName(ByVal lpszLongPath As String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal cchBuffer As Integer) As Integer
  End Function

  Private Sub New()
  End Sub
End Class